package com.blog.controller;

import com.blog.pojo.AuthUser;
import com.blog.util.TokenDecode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.oauth2.provider.authentication.OAuth2AuthenticationDetails;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/fast")
@Slf4j
public class FastDFSController {

    /**
     * 只允许某些角色访问
     * @return
     */
//    @PreAuthorize("hasAnyRole('user')")
    @GetMapping("d")
    public Map demo() {
        log.debug("ddddd");
        // 用户令牌信息-解析令牌信息-username
        Map<String, String> userInfo = TokenDecode.getUserInfo();

        Map<String, Object> map = new HashMap<>();
        map.put("aa", userInfo);
        /*
        {
            "scope": [
                "app"
            ],
            "name": null,
            "id": null,
            "exp": 1610488597,
            "authorities": [
                "user"
            ],
            "jti": "e0d1b040-d370-4f23-a8ff-26d9bba2ac8c",
            "client_id": "XcWebApp",
            "username": "lisi"
        },
         */
        map.put("bb", "123");
        map.put("cc", null);
        return map;
    }
}
